# Created with pycharm
# author:ju bai
# Date:2021/7/20
# Time:10:34
from selenium import webdriver
import time
import os

driver = webdriver.Chrome()
# 本地HTML
url = "file:///"+os.path.abspath("D:/Python/selenium2html/alert.html")
driver.get(url)
driver.maximize_window()
time.sleep(3)

driver.find_element_by_id("tooltip").click()
time.sleep(3)

# 首先获得alert的操作句柄
alert = driver.switch_to.alert
# 关闭弹窗
alert.accept()

time.sleep(6)
driver.quit()